package com.bocloud.cmp.dao.app.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import com.bocloud.cmp.dao.app.OpenshiftClusterSecurityDao;
import com.bocloud.cmp.entity.app.resource.OpenshiftClusterSecurity;
import com.bocloud.database.core.BasicDao;
/**
 * openshift集群安全Dao实现类
 * @author Zaney
 * @data:2017年4月1日
 * @describe:
 */
@Repository("openshiftClusterSecurityDao")
public class OpenshiftClusterSecurityDaoImpl extends BasicDao implements OpenshiftClusterSecurityDao {
	
	@Override
	public OpenshiftClusterSecurity save(OpenshiftClusterSecurity openshiftClusterSecurity) throws Exception {
		return (OpenshiftClusterSecurity) this.saveEntity(openshiftClusterSecurity);
	}
	
	@Override
	public boolean delete(OpenshiftClusterSecurity openshiftClusterSecurity) throws Exception {
		return this.baseDelete(openshiftClusterSecurity);
	}

	@Override
	public OpenshiftClusterSecurity getByClusterId(Long clusterId) throws Exception {
		String sql = "select * from openshift_cluster_security where openshift_cluster_id = :clusterId";
		Map<String, Object> params = new HashMap<>();
		params.put("clusterId", clusterId);
		List<Object> list = this.queryForList(sql, params, OpenshiftClusterSecurity.class);
		if (null == list || list.isEmpty()) {
			return null;
		}
		return (OpenshiftClusterSecurity) list.get(0);
	}
}
